home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group97a.txt / 000062_icon-group-sender _Mon Mar 3 18:46:44 1997.msg < prev    next >
Internet Message Format  |  2000-09-20  |  1KB

  1. Received: by cheltenham.cs.arizona.edu; Tue, 4 Mar 1997 08:22:45 MST
  2. Date: Mon, 3 Mar 1997 18:46:44 -0600
  3. Message-Id: <199703040046.SAA14304@ns1.cmpu.net>
  4. Mime-Version: 1.0
  5. Content-Type: text/plain
  6. Content-Transfer-Encoding: 7bit
  7. From: gep2@computek.net
  8. Subject: reading reals
  9. To: icon-group@cs.arizona.edu
  10. X-Mailer: SPRY Mail Version: 04.00.06.17
  11. Errors-To: icon-group-errors@cs.arizona.edu
  12. Status: RO
  13. Content-Length: 957
  14.  
  15. >...What is the Icon analog to the C
  16. programming instruction
  17.  
  18. >    scanf("%f%f", &x, &y);   ?
  19.  
  20. >That is, what is the simplest (or most standard)
  21. way to read two real numbers (with intervening
  22. and/or preceding white space) from a line of
  23. input in Icon ?
  24.  
  25. If I were doing it in SNOBOL/SPITBOL (S-BOL) I'd probably just use something 
  26. like:
  27.  
  28.    RD = "0123456789-."   ;* define real digits characters
  29.    RECORD FENCE BREAK(RD) SPAN(RD) . X BREAK(RD) SPAN(RD) . Y
  30.  
  31. One could, of course, easily enough define more demanding patterns which 
  32. required more specific formatting and which wouldn't match things like 
  33. "4.0.7-.-86", but for straightforward applications the way I proposed it would 
  34. probably work fine.
  35.  
  36. Similar approaches would probably yield similar results in Icon using string 
  37. scanning.
  38.  
  39. If you then need to have X and Y be specifically numeric type, that's easy 
  40. enough by:
  41.  
  42.    X = +X
  43.    Y = +Y
  44.  
  45. Gordon Peterson
  46. http://www.computek.net/public/gep2/
  47.  
  48.